﻿using System;
using ASPNETVN.PORTAL.Components.UI;
using ASPNETVN.PORTAL;
using System.Collections;
using ASPNETVN.PORTAL.Components.Configuration;
using ASPNETVN.PORTAL.Modules.CMS.Components;

namespace WEATHER.Modules.HOME.Controls
{
    public partial class Style2 : ModulePage
    {
        protected string GetUrl(int itemID, string moduleIdType)
        {
            Guid tabID = Guid.Empty;
            PortalDataSet ds = PortalConfiguration.GetPortalDataSet();

            foreach (PortalDataSet.TabRow tab in ds.Tab.Rows)
            {
                foreach (PortalDataSet.ModuleRow module in tab.GetModuleRows())
                {
                    if (module.ID == new Guid(this.Settings[moduleIdType].ToString()))
                    {
                        return string.Format("~/Default.aspx?tabid={0}&mid={1}&itemid={2}&page=detail", tab.ID, module.ID, itemID);
                    }
                }
            }
            return string.Format("~/Default.aspx");
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                Hashtable settings = this.Settings;
                Guid ModuleIDTTCD = new Guid(settings["CMS.ModuleIDTTCD"].ToString());
                Guid ModuleIDMT = new Guid(settings["CMS.ModuleIDMT"].ToString());
                Guid ModuleIDPPKT = new Guid(settings["CMS.ModuleIDPBKT"].ToString());
                Guid ModuleIDPTBL = new Guid(settings["CMS.ModuleIDPTBL"].ToString());

                // Tin tức - chuyên đề                
                rptTTCD.DataSource = Item.GetItemsByDisplayType(ModuleIDTTCD, "ONE");
                rptTTCD.DataBind();                
                rptTTCD1.DataSource = Item.GetItemsByDisplayType(ModuleIDTTCD, "TWO");
                rptTTCD1.DataBind();

                // Môi trường      
                rptMT.DataSource = Item.GetItemsByDisplayType(ModuleIDMT, "ONE");
                rptMT.DataBind();
                rptMT1.DataSource = Item.GetItemsByDisplayType(ModuleIDMT, "TWO");
                rptMT1.DataBind();

                // Phổ biến kiến thức  
                rptPBKT.DataSource = Item.GetItemsByDisplayType(ModuleIDPPKT, "ONE");
                rptPBKT.DataBind();
                rptPBKT1.DataSource = Item.GetItemsByDisplayType(ModuleIDPPKT, "TWO");
                rptPBKT1.DataBind();

                // Phương pháp phòng tránh bão lũ
                rptPTBL.DataSource = Item.GetItemsByDisplayType(ModuleIDPTBL, "ONE");
                rptPTBL.DataBind();
                rptPTBL1.DataSource = Item.GetItemsByDisplayType(ModuleIDPTBL, "TWO");
                rptPTBL1.DataBind();
            }
        }
    }
}